nums = [1,2,3,4,5,1,2,3,4,1,2,3,4,8,98,7,8,9]
def numberOfArithmeticSlices(nums):
    nums_len=len(nums)
    if nums_len<=2:
        return 0
    count=0
    l_pointer,r_pointer=0,1
    d=nums[r_pointer]-nums[l_pointer]
    while l_pointer<=r_pointer and r_pointer<nums_len-1:
        if nums[r_pointer+1]-nums[r_pointer]==d:
            #将r_pointer向后移动
            r_pointer+=1
        else:
            print(r_pointer-l_pointer+1)
            if r_pointer-l_pointer+1>=3:
                len_1=r_pointer-l_pointer+1
                a1,an=1,len_1-3+1
                count+=int(int((an+a1)*an)/int(2))
            l_pointer=r_pointer
            d=nums[r_pointer+1]-nums[r_pointer]

    if r_pointer-l_pointer+1>=3:
        len_1=r_pointer-l_pointer+1
        a1,an=1,len_1-3+1
        count+=int((int(an+a1)*an)/int(2))
    print(count)

numberOfArithmeticSlices(nums)